package com.wing.aspect.log;

/**
 * @Classname OperationLog
 * @Description TODO
 * @Date 2025/4/18 14:41
 * @Created by zhoudada
 */

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Description: 操作日志类
 * @Project: szgc
 * @Package: com.wing.common.entity.OperationLog
 * @Date: 2025/04/18 14:41
 * @Author: heZhou
 * @Version: 1.0
 */
@Data
@AllArgsConstructor
@TableName("t_operation_log")
@ApiModel(value = "OperationLog对象", description = "操作日志表")
public class OperationLog implements Serializable,Cloneable{

    private static final long serialVersionUID = 1L;

    /**
     * 实现 Cloneable 克隆拷贝
     * 创建一个 默认 对象，用于作为克隆的源数据
     */
    private static final OperationLog log = new OperationLog();

    /**
     * 获取克隆对象, 避免new的方式创建
     * @return {@link OperationLog}
     */
    public static OperationLog getInstance(){
        try {
            return log.clone();
        } catch (CloneNotSupportedException e) {
            return new OperationLog();
        }
    }


    /**
     * 重写克隆方法
     * @return {@link OperationLog}
     */
    public OperationLog clone() throws CloneNotSupportedException {
        return (OperationLog) super.clone();
    }

    /**
     * 私有化构造函数，不允许 new
     */
    private OperationLog(){
        this.deleted = false;
    }

    @TableId(type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("操作人ID")
    private Long operationUserId;

    @ApiModelProperty("操作人名称")
    private String operationUsername;


    @ApiModelProperty("操作模块")
    private String operationModule;

    @ApiModelProperty("具体操作事件")
    private String operationEvents;

    @ApiModelProperty("操作Url")
    private String operationUrl;

    @ApiModelProperty("操作附带数据")
    private String operationData;

    @ApiModelProperty("操作是否正常，1正常操作， 0 操作异常")
    private Boolean operationStatus;

    @ApiModelProperty("操作结果")
    private String operationResult;

    @ApiModelProperty("操作所在IP")
    private String operationIp;

    @ApiModelProperty("操作时间")
    private LocalDateTime addTime;

    @ApiModelProperty("1 删除，0 未删除")
    private Boolean deleted;

    @Override
    public String toString() {
        return "OperationLog{" +
                "id=" + id +
                ", operationUserId=" + operationUserId +
                ", operationUsername='" + operationUsername + '\'' +
                ", operationModule='" + operationModule + '\'' +
                ", operationEvents='" + operationEvents + '\'' +
                ", operationUrl='" + operationUrl + '\'' +
                ", operationData='" + operationData + '\'' +
                ", operationStatus=" + operationStatus +
                ", operationResult='" + operationResult + '\'' +
                ", operationIp='" + operationIp + '\'' +
                ", addTime=" + addTime +
                ", deleted=" + deleted +
                '}';
    }
}
